// 用axios写一个请求、响应拦截器
import axios from 'axios'

// 创建axios实例
const service = axios.create({
  baseURL: '', // url = base url + request url
  // withCredentials: true, // send cookies when cross-domain requests
  timeout: 5000 // request timeout
})

// 请求拦截器
service.interceptors.request.use((config) => {
  // do something before request is sent
  return config
})

// 响应拦截器
service.interceptors.response.use((response) => {
  // do something with response data
  return response.data
})

export default service
